<?php 
/**
 * alltosun.com 总店列表
 * ============================================================================
 * 版权所有 (C) 2009-2011 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址: http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 高昂 (gaoa@alltosun.com) $
 * $Date: 2016-2-18 下午5:25:58 $
 * $Id: $
 */

class Action
{
    private $per_page = 20;
    
    /**
     * 总店列表
     */
public function index()
    {
        $page = Request::getParam('page_no', 1);
        $status = Request::getParam('status', -1);
        $progress = Request::getParam('progress', '-1');
        $search_filter = Request::getParam('search_filter', array());

        // 拼装搜索条件
        $is_empty = 0;
        $filter = array();
        if (isset($search_filter['id']) && $search_filter['id']) {
            $filter['id'] = $search_filter['id'];
        }

        if (isset($search_filter['title']) && $search_filter['title']) {
            $filter['`title` LIKE '] = ' %'.$search_filter['title'].'% ';
        }

        if (isset($search_filter['start_date']) && $search_filter['start_date']) {
            $filter['add_time >='] = $search_filter['start_date'] . ' 00:00:00';
        }
        if (isset($search_filter['end_date']) && $search_filter['end_date']) {
            $filter['add_time <='] = $search_filter['end_date'] . ' 23:59:59';
        }

        if ($progress != '-1' || $status == 0) {
            $filter['status'] = $status;
        } else {
            $filter['1'] = 1;
        }
        
        if ('-1' != $status) {
            $filter['status'] = $status;
        } else {
            $filter['status >= '] = 0;
        }
        
        $filter['`agency_id` != '] = 0;

        $store_list = array();
        $store_list = get_data_list('user_store', $filter, ' order BY `id` DESC ', $page, $this->per_page);
        if ($store_list) {
            $type_arr = store_config::$type_arr;
            foreach ($store_list as $k => $v) {
                $user_info = _uri('user', $v['user_id']);
                if ($user_info) {
                    $store_list[$k]['user_name'] = $user_info['realname'];
                    $store_list[$k]['mobile']    = $user_info['mobile'];
                }
                if (isset($type_arr[$v['type']])) {
                    $store_list[$k]['type_name']  = $type_arr[$v['type']];
                }
                $agency_user_info = _uri('user', $v['agency_id']);
                if ($agency_user_info) {
                    $store_list[$k]['agency_user_name'] = $agency_user_info['realname'];
                    $store_list[$k]['agency_mobile']    = $agency_user_info['mobile'];
                }
                
            }
        }

        Response::assign('store_list', $store_list);
        Response::assign('status', $status);

        Response::assign('progress', $progress);
        Response::assign('search_filter', $search_filter);
        Response::display('admin/user_store_list.html');
    }
}




?>